package com.kangye.learnstudent.controller;

import com.kangye.learnstudent.entity.QuestionBank;
import com.kangye.learnstudent.entity.StudentPaper;
import com.kangye.learnstudent.entity.User;
import com.kangye.learnstudent.service.QuestionBankService;
import com.kangye.learnstudent.util.RedisStorageUtil;
import com.kangye.learnstudent.util.ViewJsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;
import java.util.List;

/**
 * @program: learndeduo
 * @description: 题库请求接口
 * @author: 高天乐
 * @create: 2021-05-17 14:03
 **/
@RestController
@CrossOrigin
@RequestMapping("/questionBank")
public class QuestionBankController {
    @Autowired
    private QuestionBankService questionBankService;
    @Autowired
    private RedisStorageUtil redisStorageUtil;

    //获取三类题添加随机生成的试卷信息
    @RequestMapping("/setQuestionBank")
    public String  setQuestionBank(StudentPaper studentPaper, Integer dropdown1, Integer dropdown2, Integer dropdown3, Integer dropdown4){
        User user = (User) redisStorageUtil.getKeyOne("studentUserRedisData");
        if (dropdown2!=0){
            List<QuestionBank> list = questionBankService.selectpaper1(dropdown1,dropdown2,user);
        }
        if (dropdown3!=0){
            List<QuestionBank> list = questionBankService.selectpaper2(dropdown1,dropdown3,user);
        }
        if (dropdown4!=0){
            List<QuestionBank> list = questionBankService.selectpaper3(dropdown1,dropdown4,user);
        }
        studentPaper.setSpCreateTime(new Timestamp(new java.util.Date().getTime()));
        return "201";
    }

}
